package org.snail.employee.mapper;

import lombok.NonNull;
import org.apache.ibatis.annotations.Param;
import org.snail.employee.bean.AddressCondition;
import org.snail.employee.bean.AddressDO;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface AddressMapper {

    /**
     * 保存address，关联群
     * @param address
     */
    public void insertAddress(AddressDO address);

    /**
     *批量插入Address
     */
    void insertBatchAddresssBydeptIdAndUserids(@Param("useridList") List<String> useridList, @Param("groupId") Long groupId, @Param("createTime") Date createTime);


    /**
     * empID和GroupID为条件 查询AddressId
     *
     * @param addressDO
     * @return
     */
    public Integer findAddressIdByEmpIdAndGroupId(AddressDO addressDO);

    /**
     * 群里移除指定的员工
     * 删除一个员工
     * @param addressCondition
     */
    public void  deleteAddress(AddressCondition addressCondition);

    /**
     * 群里移除特定员工列表
     * @param dingIds 员工钉钉
     * @param groupId 群组id
     * @param updateTime 修改时间
     */
     void  deleteAddressListByDingID(@Param("dingIds") List<String> dingIds, @Param("groupId")Long groupId, @Param("updateTime") Date updateTime);

    List<Long> findGroupIds();

    /**
     * 根据钉钉部门id,找到人员钉钉IDs
     * @param groupId 部门ID
     * @return userIds
     */
    List<String> findDIngUserIdsByGroupId(@NonNull Long groupId);


    /**
     * 根据用户的dingid，查找用户所在的部门
     * @param dingId 钉钉员工主键
     * @return 群组id列表
     */
    List findGroupIdsByDingId(String dingId);
}